﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace HTML2Image
{
    public partial class Form1 : Form
    {
        HtmlCapture hc = new HtmlCapture();
        
        public Form1()
        {
            InitializeComponent();
            label1.Text = "Ready!";
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            hc.HtmlImageCapture +=
                new HtmlCapture.HtmlCaptureEvent(hc_HtmlImageCapture);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
            hc.Create("http://" + textBox1.Text);
            label1.Text = "Processing...";
            //or
            //hc.Create("http://www.codeproject.com", new Size(200, 300)); 
        }

        void hc_HtmlImageCapture(object sender, Uri url, Bitmap image)
        {
            pictureBox1.Image = image;
            image.Save("C:/" + url.Authority + ".bmp");
            label1.Text = "Done!";
            GC.Collect();
        }
    }
}
